package main

import (
	"fmt"
)

// import "strings"

func main() {

	// fmt.Println("Hellow day1")

	// str := "hello"
	// newStr := strings.Map(func(r rune) rune {return r + 1},str)

	// fmt.Println(newStr)
	// nums()

	mm := map[string]int{"tt": 1, "kk": 22}
	mm["cc"] = 33
	m1(mm)

	fmt.Println()

	delete(mm, "tt")
	m1(mm)

	var ff, xx = mm["rr"]
	fmt.Println("ff = ", ff, ";isOk is =", xx)

	// fmt.Println(tt)
}

// 测试 for-range

func p1() {
	var name = "hahah"
	fmt.Println(name)
	for i := 1; i < 5; i++ {
		fmt.Print("第", i, "次循环\n")
	}
}

func m1(mm map[string]int) {

	for key, v := range mm {
		fmt.Printf("key is %v; val is %v\n", key, v)
	}
}

func nums() {
	var array_name [7]int

	fmt.Println("数组长度size = ", len(array_name))

	var array_name1 = [7]int{1, 2, 3, 4, 5, 6, 7}

	fmt.Println("数组长度val[0] = ", array_name1[0])
	fmt.Println("数组长度val[6] = ", array_name1[len(array_name1)-1])

	var a = [4]int{1, 3, 5, 7}
	b := [...]int{2, 4, 6, 8}
	c := [4]int{1, 3, 5, 7}

	fmt.Println(" a==b is ", a == b)
	fmt.Println(" a!=b is ", a != b)
	fmt.Println(" a==c is ", a == c)

	slice := []string{"test"}

	strs := [...]string{"one", "two", "three"}

	for i, v := range strs {
		fmt.Printf("第%d个元素是 %v\n", i+1, v)
	}

	// slice = strs[:3];
	slice = append(slice, "test2")

	fmt.Println("Slice len is = ", cap(slice))

}
